(*
This file is part of the Lustre reader

* Copyright (c) 2010, Nicola Camuffo.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*     * Redistributions of source code must retain the above copyright
*       notice, this list of conditions and the following disclaimer.
*     * Redistributions in binary form must reproduce the above copyright
*       notice, this list of conditions and the following disclaimer in the
*       documentation and/or other materials provided with the distribution.
*     * Neither the name of Nicola Camuffo, nor the
*       names of its contributors may be used to endorse or promote products
*       derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*)


open Lustypes


val idcounter : Utils.counter


(* PACKAGES / MODELS *)

(* gets package or model id by name *)
val get_pm_id : _sym -> _id

(* gets package or model name by id *)
val get_pm_name : _id -> _sym

val add_package : _sym -> _id -> unit

val get_packages : unit -> _id list

val add_model : _sym -> _id -> unit

val get_models : unit -> _id list

val add_model_instance : _sym -> _id -> unit

val get_model_instances : unit -> _id list


(* CONTAINED BY PACKAGES / MODELS OR PARAMETRIC NODES / FUNCTIONS *)

(* gets environment that contains the input object (id) *)
val get_env_container : _id -> _id

(*
(* first id is contained; second id is container *)
val set_env_as_container : _id -> _id -> unit
*)

val get_contained : _id -> _id list


(* USED BY PACKAGES / MODELS *)

val get_used : _id -> _id list

val set_as_used : _id -> _id -> unit


(* PROVIDED BY PACKAGES / MODELS *)

val get_provided : _id -> _id list

val set_as_provided : _id -> _id -> unit


(* NEEDED BY MODELS OR PARAMETRIC NODES / FUNCTIONS *)

val get_needed : _id -> _id list

val set_as_needed : _id -> _id -> unit


(* CONSTANTS *)

(* gets constant id by environment id and constant name *)
val get_constid : _id -> _sym -> _id

val get_constname : _id -> _sym

val get_constvalue : _id -> _type * _expression 

(* add constant by environment id, constant id, constant name, type and value *)
val add_const : _id -> _id -> _sym -> _type -> _expression -> unit


(* TYPES *)

(* gets type id by environment id and type name *)
val get_typeid : _id -> _sym -> _id

val get_typename : _id -> _sym

val get_typevalue : _id -> _type

(* add type by environment id, type id, type name and value *)
val add_type : _id -> _id -> _sym -> _type -> unit



(*
(* TYPE ALIASES *)

val get_typedef : _sym -> _type

val add_typedef : _sym -> _type -> unit
*)



(* NODES / FUNCTIONS *)

(* gets function or node id by environment id and the name *)
val get_fn_id : _id -> _sym -> _id

val get_fn_name : _id -> _sym

(* add function by environment id, function id and function name *)
val add_function : _id -> _id -> _sym -> unit

(* add node by environment id, node id and node name *)
val add_node : _id -> _id -> _sym -> unit


(* NODES / FUNCTIONS VARIABLES *)

(* gets input variables of a specified node *)
val get_inputs : _id -> _id list

val add_input : _id -> _id -> unit

val get_outputs : _id -> _id list

val add_output : _id -> _id -> unit

val get_locals : _id -> _id list

val add_local : _id -> _id -> unit

(* gets additional variables (created during various processes) of a specified node *)
val get_additionals : _id -> _id list

val add_additional : _id -> _id -> unit


(* VARIABLES *)

(* gets variable id by function or node id and variable name *)
val get_varid : _id -> _sym -> _id

(*
val get_all_varids : _id -> _id list
*)

val get_varname : _id -> _sym

val get_vartype : _id -> _type

(* add variable by function or node id, variable id, variable name and variable type *)
val add_var : _id -> _sym -> _id -> _type -> unit  


(* SUB VARS *)

(* gets simple var ids by tuple/record/list var id *)
val get_simple_vars : _id -> _id list

val add_simple_var : _id -> _id -> unit


(* STRUCT FIELDS *)

(* gets aux (field) var id by record id and field name *)
val get_fieldid : _id -> _sym -> _id

(* gets field name by aux var id *)
val get_fieldname : _id -> _sym

val add_fieldid : _id -> _sym -> _id -> unit


(* ASSIGNED EXPRESSIONS *)

(* gets lhs-rhs couple list by FN id *)
val get_assigned_exprs : _id -> (_typed_lhs * _typed_expression) list
	
val add_assigned_expr : _id -> _typed_lhs -> _typed_expression -> unit


(* ASSERTS *)

(* gets expression list by FN id *)
val get_asserts : _id -> _typed_expression list
	
val add_assert : _id -> _typed_expression -> unit




(* FOR DEBUG!!!! (TABLES PRINTING)*)

val entnamehash : (_id,_sym)Hashtbl.t
val pmidhash : (_sym,_id)Hashtbl.t
val packages : _id list ref
val models : _id list ref
val model_instances : _id list ref
val envcontainerhash : (_id,_id)Hashtbl.t
val containedhash : (_id,_id list)Hashtbl.t
val constidhash : ((_id * _sym),_id)Hashtbl.t
val constvaluehash : (_id,(_type * _expression))Hashtbl.t
val typeidhash : ((_id * _sym),_id)Hashtbl.t
val typevaluehash : (_id,_type)Hashtbl.t
val fnidhash : ((_id * _sym),_id)Hashtbl.t
val inputshash : (_id,_id list)Hashtbl.t
val outputshash : (_id,_id list)Hashtbl.t
val localshash : (_id,_id list)Hashtbl.t
val additionalshash : (_id,_id list)Hashtbl.t
val varidhash : ((_id * _sym),_id)Hashtbl.t
val vartypehash : (_id,_type)Hashtbl.t
val assignedexprshash : (_id,(_typed_lhs * _typed_expression) list)Hashtbl.t

